package com.ruoyi.standingbook.v2toilet.task;

import com.ruoyi.standingbook.v2toilet.logic.V2ExtendAsyncService;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.context.annotation.Configuration;
import org.springframework.scheduling.annotation.EnableScheduling;
import org.springframework.scheduling.annotation.Scheduled;

import javax.annotation.Resource;

@Configuration      //1.主要用于标记配置类，兼备Component的效果。
@EnableScheduling
public class BillFlowTask {
    @Value("${erecord.api.call:true}")
    private boolean callApi;
    @Resource
    V2ExtendAsyncService apiLogService;

    //3.添加定时任务
    @Scheduled(cron = "0/15 * * * * ?")
    //或直接指定时间间隔，例如：5秒
    //@Scheduled(fixedRate=5000)
    private void getProcessUser() {
        //            @Value("${erecord.api.call:true}")
        //            private boolean callApi;
        if (callApi) {
            apiLogService.updateProcessUser();
        }
    }

    //    @Scheduled(cron = "0 0/1 * * * ?")
    private void sendBill() {
        //        System.out.println("send bill" + DateUtil.now());
        if (callApi) {
            apiLogService.sendBills();
        }
    }

}
